<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item>
            <el-input
              size="medium"
              v-model="queryStr"
              placeholder="查询"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button size="small" type="primary" icon="el-icon-search"
              >查询</el-button
            >
          </el-form-item>
          <el-form-item>
            <el-button
              size="small"
              @click="addition(1)"
              type="primary"
              icon="el-icon-circle-plus-outline"
              >新增</el-button
            >
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="24">
        <div>
          <el-table :data="tableData" border style="width: 100%">
            <el-table-column prop="date" label="合同名称" width="">
            </el-table-column>
            <el-table-column prop="name" label="签订单位" width="">
            </el-table-column>
            <el-table-column prop="date1" label="金额" width="">
            </el-table-column>
            <el-table-column prop="address" label="回款时间"> </el-table-column>
            <el-table-column prop="address1" label="总共销售额">
            </el-table-column>
            <el-table-column prop="address1" label="合同扫描件">
            </el-table-column>
            <el-table-column prop="address1" label="合同状态">
            </el-table-column>
            <el-table-column prop="address3" label="备注"> </el-table-column>
            <el-table-column label="操作" width="180" align="center">
              <template #default="scope">
                <el-button
                  size="mini"
                  @click="handleEdit(scope.$index, scope.row)"
                  >编辑</el-button
                >
                <el-button
                  size="mini"
                  type="danger"
                  @click="handleDelete(scope.$index, scope.row)"
                  >删除</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-col>
    </el-row>
    <el-dialog
      :title="single"
      v-model="plassets"
      width="900px"
      :close-on-click-modal="false"
    >
      <el-form ref="form" :inline="true" :model="form" label-width="80px">
        <el-form-item label="合同名称">
          <el-input v-model="form.contract" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="签订单位">
          <el-input v-model="form.unitshall" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="质保金">
          <el-input v-model="form.moneys" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="金额">
          <el-input v-model="form.profile" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="编号">
          <el-input v-model="form.serial" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="付款方式">
          <el-input v-model="form.payment" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="回款时间">
          <el-date-picker
            style="width: 300px"
            v-model="form.dates"
            type="date"
            placeholder="选择日期"
            format="YYYY 年 MM 月 DD 日"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="回款总额">
          <el-input v-model="form.amount" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="总共销售额">
          <el-input v-model="form.sales_stats" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="申请开票">
          <el-checkbox v-model="form.checked" style="width: 300px"
            >申请开票</el-checkbox
          >
        </el-form-item>
        <el-form-item label="合同扫描件">
          <el-upload
            style="width: 300px"
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            multiple
            :limit="3"
            :on-exceed="handleExceed"
            :file-list="fileList"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <template #tip>
              <div class="el-upload__tip">
                只能上传 jpg/png 文件，且不超过 500kb
              </div>
            </template>
          </el-upload>
        </el-form-item>
        <el-form-item label="备注">
          <el-input
            style="width: 300px"
            v-model="form.addnote"
            type="textarea"
            :rows="2"
          ></el-input>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      queryStr: "",
      form: {
        contract: "",
        unitshall: "", //
        moneys: "",
        profile: "",
        serial: "",
        payment: "",
        dates: "",
        amount: "",
        sales_stats: "",
        checked: "",
      },
      fileList: [],
      typeList: [],
      plassets: false,
      single: "",
      under: 1,
      tableData: [
        {
          date: "......",
          name: "xxxxxxx",
          date1: "xxx",
          address: "xxxx",
          address1: "xxxx",
          address2: "xxxx",
          address3: "xxxx",
        },
      ],
    };
  },
  methods: {
    addition(index) {
      this.plassets = true;
      this.under = index;
      this.single = "新增合同";
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
  },
};
</script>

<style scoped>
.addccc {
  margin-bottom: 20px;
}
</style>